Skip to content

Conversation

ronjalh
Copy link
Member

@ronjalh ronjalh commented Oct 16, 2026

Summary

Add reusable card primitives and an initial element-variant card with a difficulty badge.

What's in it

  • Add a CardTitle that requires an explicit semantic heading level and a paragraph-based CardDescription.
  • Add a reusable difficulty badge with the letter in a navy circle and its numeric value below.
  • Move the A–J mapping into a shared utility.
  • Add a sample balance-beam element card and catalog image.
  • Document the AI-assisted changes in docs/AI_USAGE.md.

Choices

Reuse the existing design tokens and the backend's documented A–J values (0.1–1.0). Keep this first card static while the catalog integration is developed.

Testing

Not done (still open)

Part of #48

Generated with GitHub Copilot

@ronjalh ronjalh self-assigned this Oct 16, 2026
@ronjalh ronjalh force-pushed the 48-element-variant-card branch from 9f23af7 to 41097f6 Compare October 16, 2026 15:47
@ronjalh ronjalh marked this pull request as ready for review October 16, 2026 16:02
@ronjalh ronjalh requested a review from a team as a code owner October 16, 2026 16:02

return (
<span
role="img"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having role="ing" on a container can confuse accessibility tools. Considering changing to using simply aria-label og title, like this:
<span
title={
value !== undefined
? Difficulty ${letter}, value ${value.toFixed(1)}
: Difficulty ${difficulty}
}
className="inline-flex shrink-0 flex-col items-center gap-1"

A role on the container hid the visible letter and value from screen
readers. The badge now uses a title for the tooltip and a visually hidden
"Difficulty" label, so the visible text is read as it is.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a tiny polish for screen readers:

We can remove the title attribute so mouse tooltips don't clutter the UI, and wrap "Difficulty " and "Value " in <span className="sr-only"> directly next to their respective values. That way, assistive tech reads "Difficulty A, Value 0.1" cleanly without double-announcing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Just one TypeScript fix needed in card.tsx: Make as optional in CardTitleProps (as?: 'h2' | 'h3' | 'h4') and set a fallback default like as: Heading = 'h3'. Otherwise, calling <CardTitle> without as throws a type check error across the rest of the codebase.

@anettkva
Copy link
Member

DifficultyBadge: Agreed and fixed. The title is removed, and "Difficulty " and "Value " are sr-only inside the same spans as the values, so a screen reader reads "Difficulty B, Value 0.2" once.

CardTitle: I'd keep as required. It doesn't give a type error today, since the only use passes as="h2". Requiring it makes each card choose the right heading level for where it sits on the page. A default of h3 would quietly break the heading order under an h1, which matters for screen reader navigation.

Generated with Claude Code

@anettkva anettkva merged commit 9a837ab into dev Oct 21, 2026
@anettkva anettkva deleted the 48-element-variant-card branch October 21, 2026 10:39
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants